using System;
using Framework.Library.Base.Base;

namespace Framework.Portal.Layouts.Admin.Components.Database
{
    public partial class TablesAction : BaseControl
    {
        #region "Drop"

        //private void loadDropForm()
        //{
        //    pnlDrop.Visible = true;
        //    lblDropTableName.Text = objTable.Owner + "." + objTable.Name;
        //}

        protected void btnDrop_Click(object sender, EventArgs e)
        {
            //try
            //{
            //    objTable.ID = Convert.ToInt64(Request["id"]);
            //    objTable.LoadProperties();

            //    objTable.Drop();
            //    Response.Redirect(MiscUtility.AdminUrlParams(CommandController.GetCommandbyID((int)PortalControls.Table)));
            //}
            //catch (Exception ex)
            //{
            //    lblError.Visible = true;
            //    lblError.Text = "<p>" + ex.Message + "</p>";
            //}
        }

        #endregion

        #region "Rename"

        //private void loadRenameForm()
        //{
        //    pnlRename.Visible = true;
        //    lblRenameTable.Text = objTable.Owner + "." + objTable.Name;
        //    lblOwner.Text = objTable.Owner;
        //}

        protected void btnRename_Click(object sender, EventArgs e)
        {
            //try
            //{
            //    objTable.ID = Convert.ToInt64(Request["id"]);
            //    objTable.LoadProperties();
            //    objTable.Rename(txtNewName.Text);
            //    Response.Redirect(MiscUtility.AdminUrlParams(CommandController.GetCommandbyID((int)PortalControls.Table)));
            //}
            //catch (Exception ex)
            //{
            //    lblError.Visible = true;
            //    lblError.Text = "<p>" + ex.Message + "</p>";
            //}
        }

        #endregion

        //_Table objTable = new _Table();       

        private void Page_Load(object sender, EventArgs e)
        {
            //if ((!CurrentUser.IsSuperAdmin && CommandController.IsSystemModule(AdminPage.CurrentCommand.CommandID)) || !CommandController.IsAvailableForUser(AdminPage.CurrentCommand.CommandID, CurrentUser.UserID, Convert.ToInt32(cfg.Portal)))
            //    Response.Redirect(cfg.ADMIN_CMD, true);
            //if (!IsPostBack)
            //{                
            //    objTable.ID = Convert.ToInt64(Request["id"]);
            //    objTable.LoadProperties();

            //    //switch on action
            //    switch (Request.QueryString["action"].ToString())
            //    {
            //        case "drop":                        
            //            loadDropForm();
            //            break;
            //        case "rename":
            //            loadRenameForm();
            //            break;
            //    }
            //    lnkTableList.NavigateUrl = MiscUtility.AdminUrlParams(CommandController.GetCommandbyID((int)PortalControls.Table));
            //    lnkTableDetails.NavigateUrl = MiscUtility.AdminUrlParams(CommandController.GetCommandbyID((int)PortalControls.TableProperty) + "&id=" + Request.QueryString["id"].ToString());
            //}
        }
    }
}